# {{ ansible_managed }}

ETCD_NAME="{{ inventory_hostname }}"
{% set _initial_cluster = [] %}
{% for host in groups[etcd_cluster_group] %}
{%   set _host = hostvars[host]['etcd_advertise_address'] | default(hostvars[host]['ansible_host'] | default('127.0.0.1')) %}
{%   set _ = _initial_cluster.append(host ~ '=' ~ etcd_url_scheme ~ '://' ~ _host ~ ':' ~ etcd_peer_port) %}
{% endfor %}
ETCD_INITIAL_CLUSTER="{{ _initial_cluster | join(',') }}"
ETCD_DATA_DIR="{{ etcd_data_dir }}"
{% if etcd_install_type == 'proxy' %}
ETCD_PROXY="on"
{% elif etcd_install_type == 'server' %}
{% if etcd_url_scheme == 'https' %}
ETCD_CERT_FILE="{{ etcd_ssl_cert }}"
ETCD_KEY_FILE="{{ etcd_ssl_key }}"
ETCD_PEER_CERT_FILE="{{ etcd_ssl_cert }}"
ETCD_PEER_KEY_FILE="{{ etcd_ssl_key }}"
{% endif %}
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="{{ etcd_initial_token }}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{ etcd_url_scheme }}://{{ etcd_advertise_address }}:{{ etcd_peer_port }}"
ETCD_LISTEN_PEER_URLS="{{ etcd_url_scheme }}://{{ etcd_local_address }}:{{ etcd_peer_port }}"
ETCD_LISTEN_CLIENT_URLS="{{ etcd_url_scheme }}://127.0.0.1:{{ etcd_client_port }}{% if etcd_local_address != '127.0.0.1' %},{{ etcd_url_scheme }}://{{ etcd_local_address }}:{{ etcd_client_port }}{% endif %}"
ETCD_ADVERTISE_CLIENT_URLS="{{ etcd_url_scheme }}://{{ etcd_advertise_address }}:{{ etcd_client_port }}"
{% endif %}
